textview: add undo/redo support to GtkTextView
authorChristian Hergert <chergert@redhat.com>
Fri, 1 Nov 2019 18:12:21 +0000 (11:12 -0700)
committerChristian Hergert <chergert@redhat.com>
Tue, 5 Nov 2019 17:34:29 +0000 (09:34 -0800)
commit15b3c0f563d73787c574d1d03d627fbc46db59c4
tree859e7017efb44d74f43d9533779dd9c65ca1184c
parent5e341210a1cfa08a34cb257039416a97a0ab4929
textview: add undo/redo support to GtkTextView

This builds upon the GtkTextHistory helper to provide undo and redo support
for the GtkTextView widget and GtkTextBuffer object.

You can undo/redo using familiar shortcuts such as Primary+Z,
Primary+Shift+Z, ad Primary+Y.

Developers that wish to disable undo, should set the
GtkTextBuffer:enable-undo property to FALSE.

You can wrap irreversible actions
gtk_text_buffer_begin_irreversible_action() and
gtk_text_buffer_end_irreversible_action(). This will cause the undo stack
to drop all undo/redo actions and the changes made between them will be
the "initial state" of the buffer.

Calling gtk_text_buffer_set_text() will do this automatically for you.
docs/reference/gtk/gtk4-sections.txt
docs/reference/gtk/text_widget.sgml
gtk/gtktextbuffer.c
gtk/gtktextbuffer.h
gtk/gtktextprivate.h
gtk/gtktextview.c